#include "../include/TransmitPacket.hpp"
#include "../include/util.hpp"

#include <cstdio>

TransmitPacket::TransmitPacket(){}
TransmitPacket::~TransmitPacket(){}


const uint64_t broadcast_64 = 0x000000000000FFFF;
const uint16_t broadcast_16 = 0xFFFE;

enum broadcast_radius {
    max_hops = 0x0
};


void TransmitPacket::assemble_payload(  uint8_t     frame_id,
                                        uint32_t    lower_addr,
                                        std::string data) {
    payload.clear();
    payload.push_back(tx_request_ft);
    payload.push_back(frame_id);

    push_back_32(&payload, upper_addr);
    push_back_32(&payload, lower_addr);
    push_back_16(&payload, broadcast_16);

    payload.push_back(max_hops);

    payload.push_back(0x0); /* Options (none) */

    for (int i = 0; data[i] != '\0'; ++i) {
        payload.push_back(data[i]);
    }
}


std::vector<uint8_t> * TransmitPacket::get_payload() {
    return (&payload);
}
